<template>
  <div id="app">
    <router-view/>
    <FooterGuide class="footer" v-if="filterPath"/>
  </div>
</template>

<script>
  import FooterGuide from "./components/FooterGuide/FooterGuide";
  import {RECEIVE_ADDRESS, RECEIVE_CATEGORIES, RECEIVE_SHOPS, RECEIVE_USERINFO} from "./store/mutation-types";
  export default {
    name: 'App',
    components:{
      FooterGuide
    },
    computed:{
      // eslint-disable-next-line vue/return-in-computed-property
      filterPath() {
        if (this.$route.path === '/shop/goods' || this.$route.path === '/login' ||this.$route.path === '/shop/info'||this.$route.path === '/shop/rating') {
          return false
        } else{
          return true
        }
      }
    },
    methods:{
      async fetchFoodCategory(){
        const res = await this.$http.get(`api/index_category`)
        this.$store.commit(RECEIVE_CATEGORIES,res.data.data)
      },
      async fetchAddress(){
        const geohash = this.$store.state.latitude + ',' + this.$store.state.longitude
        const res = await this.$http.get(`api/position/${geohash}`)
        this.$store.commit(RECEIVE_ADDRESS,res.data.data)
      },
      async fetchShops(){
        const {latitude,longitude} = this.$store.state
        const res = await this.$http.get(`api/shops/`,{latitude,longitude})
        this.$store.commit(RECEIVE_SHOPS,res.data.data)
      },
      async getUserInfo(){
        const res = await this.$http.get(`api/userinfo`)
        if(res.data.code === 0){
          this.$store.commit(RECEIVE_USERINFO,res.data.data)
        }
      },
    },
    mounted() {
      this.getUserInfo()
    },
    created() {
      this.fetchAddress()
      this.fetchShops()
      this.fetchFoodCategory()
    },
  }
</script>

<style lang="scss" scoped>
  ::-webkit-scrollbar {
    width: 0 !important;
  }
  ::-webkit-scrollbar {
    width: 0 !important;
    height: 0;
  }
</style>
